const tree = require('./tree');

const reverseBinaryTree = (root) => {
	if (root == null) {
		return null;
	}
	const temp = root.left;
	root.left = root.right;
	root.right = temp;
	if (root.left != null) {
		reverseBinaryTree(root.left);
	}
	if (root.right != null) {
		reverseBinaryTree(root.right);
	}
	return root;
}

const result = reverseBinaryTree(tree);

console.log(JSON.stringify(result, null, '\t'))
